package gunfire.relics;

import basemod.abstracts.CustomRelic;
import com.badlogic.gdx.graphics.Texture;
import com.megacrit.cardcrawl.actions.common.GainEnergyAction;
import com.megacrit.cardcrawl.actions.common.RelicAboveCreatureAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import gunfire.GunfireMod;
import gunfire.util.TextureLoader;

import static gunfire.GunfireMod.makeRelicOutlinePath;
import static gunfire.GunfireMod.makeRelicPath;

public class MercilessCombo extends CustomRelic {

    public static final String ID = GunfireMod.makeID("MercilessCombo");
    private static final Texture IMG = TextureLoader.getTexture(makeRelicPath("MercilessCombo.png"));
    private static final Texture OUTLINE = TextureLoader.getTexture(makeRelicOutlinePath("blank.png"));

    public MercilessCombo() {
        super(ID, IMG, OUTLINE, RelicTier.BOSS, LandingSound.CLINK);
        this.counter = 0;
    }

    @Override
    public void atTurnStart() {
        this.counter = 0;
        this.pulse = false;
    }

    @Override
    public void onPlayCard(AbstractCard c, AbstractMonster m) {
        if(c.type == AbstractCard.CardType.ATTACK){
            this.counter++;
            if(this.counter == 3){
                this.counter = 0;
                this.flash();
                this.pulse = false;
                this.addToBot(new RelicAboveCreatureAction(AbstractDungeon.player, this));
                this.addToBot(new GainEnergyAction(1));
            } else if(this.counter == 2){
                this.beginPulse();
                this.pulse = true;
            }
        } else {
            this.counter = 0;
        }
    }

    @Override
    public String getUpdatedDescription() {
        return DESCRIPTIONS[0];
    }

    @Override
    public AbstractRelic makeCopy() {
        return new MercilessCombo();
    }
}
